<?php
namespace app\services;
use Firebase\JWT\JWT;
use Firebase\JWT\Key;

class JwtServices{

    // Jwt加密
    public static function JwtEncode($uid){
        $key = '2008a';
        $payload = [
//            'iss' => 'http://example.org',
//            'aud' => 'http://example.com',
//            'iat' => 1356999524,
//            'nbf' => 1357000000,

            'uid'=>$uid
        ];

        $jwt = JWT::encode($payload, $key, 'HS256');
        return $jwt;
    }

    // Jwt解密
    public static function JwtDecode($jwt){

        $key = '2008a';

        $decoded = JWT::decode($jwt, new Key($key, 'HS256'));

        return (array) $decoded;
    }

}